Count the number of Monday of the 1st day of the MonthΒΆ
Count the number of monday of the 1st day of the month from 2015 to 2016.
import datetime
from datetime import datetime
cnt_mondays = 0
months = range(1, 13)
for year in range(2015, 2017):
for month in months:
if datetime(year, month, 1).weekday() == 0:
cnt_mondays += 1
print(cnt_mondays)
Output:
3